package com.lmx.repoDomain.tmodel;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;


import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;
/**
 * 健康档案表
 * @author jing
 *
 */
@JsonApiResource(type = "healthrecord")
@Table(name = "tnb_health_records")
@Entity
public class HealthRecord extends BaseEntity {

	private Customer customer;  //对应的老人
	
	private String geneticHistory;  //遗传病史
	
	//下边这些表示的是对应的其他表数据
	private List<MedicalPaymentMode> medicalpaymentmodes = new ArrayList<MedicalPaymentMode>(); //医疗支付的方式
	
	private List<DrugAllegy> drugallegys = new ArrayList<DrugAllegy>(); //药物过敏史
	
	private List<ExposureHistory> exposurehistorys = new ArrayList<ExposureHistory>(); //暴露史

	private List<DiseaseHistory> diseasehistorys = new ArrayList<DiseaseHistory>(); //疾病史
	
	private List<FamilyHistory> familyhistorys = new ArrayList<FamilyHistory>(); //家族史
	
	private List<DiseaseCondition> diseaseconditions = new ArrayList<DiseaseCondition>(); //疾病情况，可选无残疾  视力残疾  听力残疾  言语残疾  肢体残疾  智力残疾  精神残疾  其他残疾 
    
	private List<OperationHistory> operationhistorys = new ArrayList<OperationHistory>(); //手术史
	
	private List<InjuryHistory> injuryhistorys = new ArrayList<InjuryHistory>();  //外伤史
	
	private List<BloodHistory> bloodhistorys = new ArrayList<BloodHistory>(); //输血史
	

	
	@Column(name="genetic_history")
	public String getGeneticHistory() {
		return geneticHistory;
	}   

	public void setGeneticHistory(String geneticHistory) {
		this.geneticHistory = geneticHistory;
	}  

	@JsonApiToMany
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "healthrecord")
	public List<MedicalPaymentMode> getMedicalpaymentmodes() {
		return medicalpaymentmodes;
	}

	public void setMedicalpaymentmodes(List<MedicalPaymentMode> medicalpaymentmodes) {
		this.medicalpaymentmodes = medicalpaymentmodes;
	}

	@JsonApiToMany
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "healthrecord")
	public List<DrugAllegy> getDrugallegys() {
		return drugallegys;
	}

	public void setDrugallegys(List<DrugAllegy> drugallegys) {
		this.drugallegys = drugallegys;
	}

	@JsonApiToMany
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "healthrecord")
	public List<ExposureHistory> getExposurehistorys() {
		return exposurehistorys;
	}

	public void setExposurehistorys(List<ExposureHistory> exposurehistorys) {
		this.exposurehistorys = exposurehistorys;
	}

	@JsonApiToMany
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "healthrecord")
	public List<DiseaseHistory> getDiseasehistorys() {
		return diseasehistorys;
	} 

	public void setDiseasehistorys(List<DiseaseHistory> diseasehistorys) {
		this.diseasehistorys = diseasehistorys;
	}

	@JsonApiToMany
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "healthrecord")
	public List<FamilyHistory> getFamilyhistorys() {
		return familyhistorys;
	}

	public void setFamilyhistorys(List<FamilyHistory> familyhistorys) {
		this.familyhistorys = familyhistorys;
	}

	@JsonApiToMany
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "healthrecord")
	public List<DiseaseCondition> getDiseaseconditions() {
		return diseaseconditions;
	}

	public void setDiseaseconditions(List<DiseaseCondition> diseaseconditions) {
		this.diseaseconditions = diseaseconditions;
	}

	@JsonApiToMany
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "healthrecord")
	public List<OperationHistory> getOperationhistorys() {
		return operationhistorys;
	}

	public void setOperationhistorys(List<OperationHistory> operationhistorys) {
		this.operationhistorys = operationhistorys;
	}

	@JsonApiToMany
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "healthrecord")
	public List<InjuryHistory> getInjuryhistorys() {
		return injuryhistorys;
	}

	public void setInjuryhistorys(List<InjuryHistory> injuryhistorys) {
		this.injuryhistorys = injuryhistorys;
	}

	@JsonApiToMany
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "healthrecord")
	public List<BloodHistory> getBloodhistorys() {
		return bloodhistorys;
	}

	public void setBloodhistorys(List<BloodHistory> bloodhistorys) {
		this.bloodhistorys = bloodhistorys;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "customer_id", foreignKey = @ForeignKey(name = "null"))
	public Customer getCustomer() {
		return customer;
	}  

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}


}
